package com.sooncode.project.focusservice.controller;

import com.sooncode.project.focusservice._.base.Utils;
import com.sooncode.project.focusservice.model.TestItem;
import com.sooncode.project.focusservice.service.TestItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("testItem")
public class TestItemController {
    @Autowired
    private TestItemService service;

    @PostMapping("testItem")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }
    @PutMapping("testItem")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        return service.modify(id,map);
    }
    @DeleteMapping("testItem")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("testItems")
    public List<TestItem> getList(@RequestParam Map map){
        map.remove("pageSize");
        map.remove("pageIndex");
        Utils.mapValueTrim(map);
        return service.getList(map);
    }
}
